		$(function(){

			$('#roletree').tree({
				dnd: true, 
				checkbox: true,
				url: '../../role/roletree.json',
				onClick:function(node){
					//alert('you click '+node.text);
				ajaxRoleUserTable("../../user/roleuser.json?roleId="+node.id);	
				$('#roleUserTable').datagrid('options').title=node.text+"角色的用户列表";
				$('#selectRoleId').val(node.id);
				$('#selectRoleName').val(node.text);
				},
				onDrop: function(targetNode, source, point){  				
					
				      var target= $("#roletree").tree('getNode',targetNode);
				      alert(source.id+source.text+" \n"+point+" \n"+target.text.toString()+target.id.toString());
				     
				      /* $.ajax({  
				           url: '...',  
				           type: 'post',  
				           dataType: 'json',  
				           data: {  
				               id: source.id,  
				               targetId: targetId,  
				               point: point  
				           }  
				       });  */
				   }  
			});
			
		});
		function reload(){
			$('#roletree').tree('reload');
		}
		function getChildNodes(){
			var node = $('#roletree').tree('getSelected');
			if (node){
				var children = $('#roletree').tree('getChildNodes', node.target);
				var s = '';
				for(var i=0; i<children.length; i++){
					s += children[i].text + ',';
				}
				alert(s);
			}
		}
		function getChecked(){
			var nodes = $('#roletree').tree('getChecked');
			var s = '';
			for(var i=0; i<nodes.length; i++){
				if (s != '') s += ',';
				s += nodes[i].text;
			}
			alert(s);
		}
		function getSelected(){
			var node = $('#roletree').tree('getSelected');
			
			//alert(node.text+node.id);
		}
		function collapse(){
			var node = $('#roletree').tree('getSelected');
			$('#roletree').tree('collapse',node.target);
		}
		function expand(){
			var node = $('#roletree').tree('getSelected');
			$('#roletree').tree('expand',node.target);
		}
		function collapseAll(){
			$('#roletree').tree('collapseAll');
		}
		function expandAll(){
			$('#roletree').tree('expandAll');
		}
		function append(){
			var node = $('#roletree').tree('getSelected');
			$('#roletree').tree('append',{
				parent: node.target,
				data:[{
					text:'new1',
					checked:true
				},{
					text:'new2',
					state:'closed',
					children:[{
						text:'subnew1'
					},{
						text:'subnew2'
					}]
				}]
			});
		}
		function remove(){
			var node = $('#roletree').tree('getSelected');
			$('#roletree').tree('remove', node.target);
		}
		function update(){
			var node = $('#roletree').tree('getSelected');
			if (node){
				node.text = '<span style="font-weight:bold">new text</span>';
				node.iconCls = 'icon-save';
				$('#roletree').tree('update', node);
			}
		}
		function isLeaf(){
			var node = $('#roletree').tree('getSelected');
			var b = $('#roletree').tree('isLeaf', node.target);
	
		}
